import Layout from '@/layout/index.vue'

export const routes = [
  {
    path: '/',
    name: 'Home',
    component: Layout,
    redirect: '/home',
    meta: {
      title: '网站首页'
    },
    children: [
      {
        path: 'home',
        name: 'home-index',
        component: () => import('@/views/home/index.vue'),
        meta: {
          title: 'Dashboard',
          hidden: true,
          activeName:'Home'
        }
      }
    ]
  }
]

const changeRoutes = (routes) => {
    return routes.reduce((pre, cur) => {
      let item = {
        name: cur.name,
        meta: cur.meta
      }
      if (cur.children && cur.children.length > 0) {
        item.children = changeRoutes(cur.children)
      }
      pre.push(item)
      return pre
    }, [])
  }
  

export const defaultRoutes = changeRoutes(routes)

